package com.zhj.agent.interceptor.resttemplate.sync;

import com.zhj.agent.core.RuntimeContextManager;
import com.zhj.agent.support.InstanceMethodsAroundInterceptor;

import java.lang.reflect.Method;

public class RestExecuteInterceptor implements InstanceMethodsAroundInterceptor {

    @Override
    public void beforeMethod(Object objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes) throws Throwable {

    }

    @Override
    public Object afterMethod(Object objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object result) throws Throwable {
        return result;
    }

    @Override
    public void handleMethodException(Object objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
        //调用异常之后打印调用链路
        RuntimeContextManager.printTraceLog();
    }
}
